<?php

class admin_template_system_menu_listing extends admin_theme
{


	
	protected function head()
	{
	?>
<link type="text/css" rel="stylesheet" href="apps/system/templates/menu/css/menu.css">
<script type="text/javascript" language="javascript" src="apps/system/templates/menu/js/menu.js"></script>
	<?php
	}
	
	protected function center()
	{
		$groups = $this->get('groups');
		$group_id = $this->get('group_id');
		
		echo '<div class="groups">';
		echo '<ul>';
		foreach($groups as $group)
		{
			echo '<li';
			if($group_id==$group->id) echo ' class="on"';;
			echo '><a href="./?action=system.menu.listing&group_id='.$group->id.'">'.$group->name.'</a></li>';
		}
		echo '</ul>';
		echo '</div>';
		
		$menus = $this->get('menus');
		foreach($menus as $menu)
		{
		    $str = '<select name="target[]">';
		    $str .= '<option value="_self"';
		    if($menu->target=='_self')  $str .= ' selected="selected"';
		    $str .= '>当前窗口</option>';
		    $str .= '<option value="_blank"';
		    if($menu->target=='_blank')  $str .= ' selected="selected"';
		    $str .= '>新窗口</option>';
		    $str .= '<option value="_parent"';
		    if($menu->target=='_parent')  $str .= ' selected="selected"';
		    $str .= '>父窗口</option>';
		    $str .= '<option value="_top"';
		    if($menu->target=='_parent')  $str .= ' selected="selected"';
		    $str .= '>最顶层窗口</option>';
		    $str .= '</select>';
		    $menu->target = $str;
		}
		
		$target_default = '<select name="target[]">';
	    $target_default .= '<option value="_self" selected="selected">当前窗口</option>';
	    $target_default .= '<option value="_blank">新窗口</option>';
	    $target_default .= '<option value="_parent">父窗口</option>';
	    $target_default .= '<option value="_top">最顶层窗口</option>';
	    $target_default .= '</select>';

		$ui_category = bone::get_admin_ui('category');
		$ui_category->set_data($this->get('menus'));
		
		$ui_category->set_fields(
    		array(
    			'name'=>'url',
    			'label'=>'链接到',
    			'align'=>'center',
    		    'width'=>'300',
    		    'template'=>'<input type="text" name="url[]" value="{url}" size="40" maxlength="120" /> <a href="javascript:;" onclick="javascript:setLink(this);">设置</a>',
    			'default'=>'<input type="text" name="url[]" size="40" maxlength="120" /> <a href="javascript:;" onclick="javascript:setLink(this);">设置</a>'   		    
    		),
    		array(
    			'name'=>'target',
    			'label'=>'打开类型',
    			'align'=>'center',
    		    'width'=>'140',
    			'default'=>$target_default   		    
    		)
		);
		$ui_category->set_footer('<input type="hidden" name="group_id" value="'.$group_id.'">');
		$ui_category->display();
		?>
		<div class="comment">
			<ul>
				<li>* 添加多级菜单时需要模板支持，子菜单保存后方可添加更深级子菜单。</li>
				<li>* 打开类型中的  “父窗口” 和  “最顶层窗口” 是当页面被包含在框架中的情况下才需要设置的。</li>
			</ul>
		</div>
		<?php
	}	

}
?>